package month4.day15;

public class S4 {
    public static void main(String[] args) {
        StringBuffer buffer = new StringBuffer();
        StringBuilder builder = new StringBuilder();
        long bufferStartTime = System.currentTimeMillis();
        for(int i = 0;i < 100000;i++){
            buffer.append("%");
        }
        long bufferEndTime = System.currentTimeMillis();

        long builderStartTime = System.currentTimeMillis();
        for(int i = 0;i < 100000;i++){
            builder.append("%");
        }
        long builderEndTime = System.currentTimeMillis();

        long time = (bufferEndTime - bufferStartTime) -(builderEndTime - builderStartTime);
        if(time > 0){
            System.out.println("拼接10万个相同的字符串,StringBuffer比StringBuilder快" + time + "ms");
        }else {
            System.out.println("拼接10万个相同的字符串,StringBuffer比StringBuilder慢" + -time + "ms");

        }
    }
}
